#include<iostream>
using namespace std;
#include<vector>
#include<queue>
class Solution {
public:
    int minOperations(vector<int>& nums, int k) {
        int ans = 0;
        priority_queue<long long, vector<long long>, greater<long long>> que;
        for (auto& e : nums)
            if (e < k)
                que.push(e);
        while (que.size() > 1) {
            ++ans;
            long long a = que.top();
            que.pop();
            long long b = que.top();
            que.pop();
            long long now = min(a, b) * 2 + max(a, b);
            if (now < k)
                que.push(now);
        }
        return ans + que.size();
    }
};